.TH std::ratio_equal 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ratio_equal \- std::ratio_equal

.SH Synopsis
   Defined in header <ratio>
   template< class R1, class R2 >
   struct ratio_equal : std::integral_constant<bool, /* see below */> {   \fI(since C++11)\fP
   };

   If the ratios R1 and R2 are equal, provides the member constant value equal true.
   Otherwise, value is false.

.SH Member constants

   value    true if R1::num == R2::num && R1::den == R2::den, false otherwise
   \fB[static]\fP \fI(public static member constant)\fP

.SH Member functions

   operator bool converts the object to bool, returns value
                 \fI(public member function)\fP
   operator()    returns value
   \fI(C++14)\fP       \fI(public member function)\fP

.SH Member types

   Type       Definition
   value_type bool
   type       std::integral_constant<bool, value>

.SH Possible implementation

   template< class R1, class R2 >
   struct ratio_equal : public std::integral_constant <
                                    bool,
                                    R1::num == R2::num && R1::den == R2::den
                               > {};

.SH Example


// Run this code

 #include <iostream>
 #include <ratio>

 int main()
 {
     constexpr bool equ = std::ratio_equal_v<std::ratio<2,3>,
                                             std::ratio<4,6>>;
     static_assert(equ == true);
     std::cout << "2/3 " << (equ ? "==" : "!=") << " 4/6\\n";
 }

.SH Output:

 2/3 == 4/6

.SH See also

   ratio_not_equal compares two ratio objects for inequality at compile-time
   \fI(C++11)\fP         \fI(class template)\fP
